<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="static com.testtask.rightandabove.tools.UrlList.*"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Image CD List</title>
    </head>
    <body>
        <%@ include file="index.jsp" %> 
        <h2>CD List</h2>
        <c:forEach var="cd" items="${cdEntities}">
            <table>
                <tr>
                    <td>Title:</td>
                    <td><c:out value="${cd.title}" /></td>
                </tr>
                <tr>
                    <td>Artist:</td>
                    <td><c:out value="${cd.artist}" /></td>
                </tr>
                <tr>
                    <td>Country:</td>
                    <td><c:out value="${cd.country}" /></td>
                </tr>
                <tr>
                    <td>Company:</td>
                    <td><c:out value="${cd.company}" /></td>
                </tr>
                <tr>
                    <td>Price:</td>
                    <td><c:out value="${cd.price}" /></td>
                </tr>
                <tr>
                    <td>Year:</td>
                    <td><c:out value="${cd.year}" /></td>
                </tr>
            </table><br /><br />
        </c:forEach> 

        <c:choose>
            <c:when test="${lastPage != 1 && lastPage != null}">
                <a href="<%=request.getContextPath()%>/<%=DATAIMAGE_URL%>?page=0">First Page</a> |
            </c:when>
        </c:choose> 
        <c:choose>        
            <c:when test="${page!= 0 && lastPage != null}">
                <a href="<%=request.getContextPath()%>/<%=DATAIMAGE_URL%>?page=<c:out value="${page-1}" />">Previous Page</a> |
            </c:when>
        </c:choose> 
        <c:choose> 
            <c:when test="${page+1!= lastPage && lastPage != null}">
                <a href="<%=request.getContextPath()%>/<%=DATAIMAGE_URL%>?page=<c:out value="${page+1}" />">Next Page</a> |
            </c:when>
        </c:choose> 
        <c:choose>         
            <c:when test="${lastPage != 1 && lastPage != null}">
                <a href="<%=request.getContextPath()%>/<%=DATAIMAGE_URL%>?page=<c:out value="${lastPage-1}" />">Last Page</a>
            </c:when>
        </c:choose>   <br />  
        <c:choose>
            <c:when test="${lastPage == null}">
                <p>List is empty</p>
            </c:when>
            <c:otherwise>        
                <p>Page: <c:out value="${page+1}" />/<c:out value="${lastPage}" /></p>
            </c:otherwise>
        </c:choose> 


    </body>
</html>
